package com.zwr.sheller.shop.service.impl;

import com.zwr.sheller.core.pojo.Reduction;
import com.zwr.sheller.shop.mapper.ReductionMapper;
import com.zwr.sheller.shop.service.ReductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *
 *@author Kang
 *@date
 */
@Service("reductionService")
public class ReductionServiceImpl implements ReductionService {
    @Autowired(required = false)
    ReductionMapper reductionMapper;

    @Override
    public Integer add(Reduction reduction) {

        //商户id在t
        Long marketersId=1L;
        reduction.setMarketersId(marketersId);
        int insert = reductionMapper.insert(reduction);
        return insert;
    }

    @Override
    public Integer delete(Long id) {

        Long marketersId=1L;
        Reduction reduction=new Reduction();
        reduction.setMarketersId(marketersId);
        reduction.setId(id);
        int delete = reductionMapper.delete(reduction);
        return delete;
    }

    @Override
    public Integer deleteMore(ArrayList list) {


        return null;
    }

    @Override
    public Integer update(Reduction reduction) {
        int i = reductionMapper.updateByPrimaryKeySelective(reduction);
        return i;
    }

    @Override
    public List<Map<String, Object>> selectByNameByTimeByManner(Integer manner, Integer timePeriod, String name, Integer page) {
        Long marketersId=1L;
        List<Map<String, Object>> mapList = reductionMapper.selectByNameByTimeByManner(manner, timePeriod, name, marketersId, (page - 1) * 3);


        return mapList;
    }

    @Override
    public Map selectByNameByTimeByMannerCount(Integer manner, Integer timePeriod, String name) {
        Long marketersId=1L;
        Map map = reductionMapper.selectByNameByTimeByMannerCount(manner, timePeriod, name, marketersId);

        return map;
    }
}
